import { 
  SHOW_MODAL_CHANGE_PWD, 
  HIDE_MODAL_CHANGE_PWD,
  GET_DATA_SUCCESS,
  GET_DATA_FAIL,
  RESET_PASS_WORD,
  RESET_PASS_WORD_SUCCESS,
  RESET_PASS_WORD_FAIL,
  SHOW_PASSWORD,
  HIDDEN_PASSWORD
} from '@/actions/main'

const initState = {
  modalVisible: false,
  data: {},
  resetButtonLoading: false,
  isPassWordShow: false,
}

const mainReducer = (state = initState, action) => {
  switch (action.type) {
    case SHOW_MODAL_CHANGE_PWD:
      return { ...state, modalVisible: true }
      break;

    case HIDE_MODAL_CHANGE_PWD:
      return { ...state, modalVisible: false }
      break;

    case GET_DATA_SUCCESS:
      return { ...state, data: action.data }
      break;
    
    case GET_DATA_FAIL:
      return { ...state, data: {}}
      break;

    case RESET_PASS_WORD:
      return { ...state, resetButtonLoading: true }
      break;

    case RESET_PASS_WORD_SUCCESS:
    case RESET_PASS_WORD_FAIL:
      return { ...state, resetButtonLoading: false }
      break;

    case SHOW_PASSWORD:
      return { ...state, isPassWordShow: true }
      break;

    case HIDDEN_PASSWORD:
      return { ...state, isPassWordShow: false }
      break

    default:
      return state
      break;
  }
}

export default mainReducer